#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/time.h>

void fun2(){
    printf("son sigint fun2\n");
   
}

int main(void){
    pid_t pid=fork();
    signal(SIGCHLD,fun2);//子进程退出捕获信号

    if(0==pid){
        //子进程
        int i=0;
        while(1){
           printf("pid:%d  ppid:%d \n",getpid(),getppid());
            printf("is son process\n"); 
            sleep(2);
            exit(0);
        } 
    }else{ 
        printf("is father process\n"); 
        printf("fatherpid: %d\n",getpid()); 
	sleep(10);
    }

    return 0;
}
/*
 * is father process
 * fatherpid: 22222
 * pid:11111  ppid:222222
 * is son process
 * son sigint fun2

 */
